package coco.mogodb.com.module.drug.controller;

import coco.mogodb.com.common.dto.TempMap;
import coco.mogodb.com.module.drug.entity.PharmacyDrugs;
import coco.mogodb.com.module.drug.service.DrugsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/drugs")
public class DrugsController {

    @Autowired
    private DrugsService drugsService;

    @PostMapping("/getPharmacyDrugsPage")
    public ResponseEntity<Object> getPharmacyDrugsPage(@RequestBody TempMap dto) {

        return drugsService.findByCondition(dto);
    }

    @PostMapping("/addPharmacyDrugs")
    public ResponseEntity<Object> getDrugsPage(@RequestBody PharmacyDrugs dto) {

        return drugsService.save(dto);
    }

    @GetMapping("/findById")
    public ResponseEntity<Object> findById(@RequestParam("id") String id) {

        return drugsService.findById(id);
    }
}
